package com.stephen.test;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author yuanyl29137
 * @classname com.stephen.test
 * @date 2021/8/9 13:53
 * @Description
 */
@RestController
@RequestMapping("/greet")
@Api(description = "测试接口")
public class GreetController {

    @Autowired
    private List<GreetService> greetServiceList;

    @Autowired
    private Map<String, GreetService> greetServiceMap;

    @RequestMapping(value = "/test/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取信息", notes = "测试自动注入")
    public String getbook5(@ApiParam("id编号") @PathVariable("id") Long id) {
        System.out.println("==set====");
        for (Map.Entry<String, GreetService> entry : greetServiceMap.entrySet()) {
            System.out.println(entry.getValue().sayHello("" + id));
        }
        System.out.println("==list====");
        for (GreetService greetService : greetServiceList) {
            System.out.println(greetService.sayHello("" + id));
        }
        return "" + id;
    }
}
